/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cpasl;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;

/**
 *
 * @author seanm_000
 */
public class HearingGridPane extends GridPane {
    
    public HearingGridPane() {
        setAlignment(Pos.CENTER);
        setHgap(15);
        setVgap(15);
        
        Label hearingLabel = new Label("What is your hearing status?");
        final ToggleGroup hearingGroup = new ToggleGroup();
        RadioButton noneButton = new RadioButton("No hearing loss");
        noneButton.setUserData("A");
        noneButton.setToggleGroup(hearingGroup);
        noneButton.setSelected(true);
        RadioButton partialButton = new RadioButton("Partial hearing loss");
        partialButton.setUserData("B");
        partialButton.setToggleGroup(hearingGroup);
        RadioButton fullButton = new RadioButton("Full hearing loss");
        fullButton.setUserData("C");
        fullButton.setToggleGroup(hearingGroup);
        
        Button nextButton = new Button();
        nextButton.setText("Next");
        nextButton.setId("next-button");
        nextButton.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                String userData = (String) ((RadioButton) hearingGroup.getSelectedToggle()).getUserData();
                CpaslManager.getInstance().setHearingStatus(userData);
                if (userData.equals("A")) {
                    CpaslManager.getInstance().switchToDisplay(Groups.NATIVE, 0); 
                }
                else {
                    CpaslManager.getInstance().switchToDisplay(Groups.BIG_D, 0);
                }
            }
        });
        
        add(hearingLabel, 0, 0);
        add(noneButton, 0, 1);
        add(partialButton, 0, 2);
        add(fullButton, 0, 3);
        add(nextButton, 0, 4);
    }
    
}
